﻿//using System;
//using System.Collections.Generic;
//using System.Text;
//using ZhCun.Framework.DataAccess.DAL;
//using ZhCun.Framework.Common.Models.TableModel;
//using ZhCun.Framework.Common.Models;
//using System.Data;
//using System.Data.Common;
//using ZhCun.Framework.Common;
//using ZhCun.Framework.Common.Models.ProcedureModel;
//using ZhCun.Framework.DataAccess.DataDelegate;

//namespace ZhCun.Framework.DataAccess.BLL
//{
//    public abstract class BLLBase<TModel> where TModel : ModelBase, new()
//    {
//        public BLLBase()
//        { }

//        /// <summary>
//        /// dal 需要一个所对应表的DAL对象
//        /// </summary>
//        public BLLBase(DalBase<TModel> dal)
//        {
//            this._DAL = dal;
//        }

//        protected DalBase<TModel> _DAL;

//        //protected event BLLInsertHandle<TModel> InsertBefore;
//        //protected event BLLUpdateHandle<TModel> UpdateBefore;
//        //protected event BLLSearchHandle SearchBefore;

//        //ModelDefaultRule
//        //供子类使用的过的当前时间,这个方法通常是返回服务器的时间方法
//        protected DateTime GetCurrentTime()
//        {
//            return DateTime.Now;
//        }

//        #region 增加,删除,修改

//        public virtual int Add( params TModel[] models)
//        {
//            if (InsertBefore != null)
//            {
//                InsertBefore(models);
//            }
//            return _DAL.Add( models);
//        }
     
//        #region 更新的几个重载

//        /// <summary>
//        /// 更新的第一层方法
//        /// </summary>
//        /// <param name="tranId">事务id</param>
//        /// <param name="fields">要更新的字段</param>
//        /// <param name="sqlWhere">sqlWhere条件</param>
//        /// <param name="dbParams">参数</param>
//        /// <param name="models">要更新的实体</param>
//        /// <returns>返回所影响行数</returns>
//        public virtual int Update(string[] fields, string sqlWhere, Dictionary<string, object> dbParams, params TModel[] models)
//        {
//            if (UpdateBefore != null)
//            {
//                UpdateBefore(fields, models);
//            }
//            return _DAL.Update(fields, sqlWhere, dbParams, models);
//        }

//        public int Update(string[] fields, params TModel[] models)
//        {
//            return Update(fields, null, null, models);
//        }
//        public int Update(string[] fields, TModel models, params DbWhereModel[][] dbWhereModel)
//        {
//            //按条件更新时只允许输入一个实体和指定字段来更新
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParams = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParams, dbWhereModel);
//            return Update( fields, sqlWhere.ToString(), dbParams, models);
//        }
//        public int Update(string[] fields, TModel models, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParams = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParams, dbWhereModel);
//            return Update(fields, sqlWhere.ToString(), dbParams, models);
//        }
        
//        #endregion

//        public virtual int Delete( params object[] pkValues)
//        {
//            return _DAL.Delete(pkValues);
//        }
       
//        public virtual int ExecuteBySQL(string sqlText, Dictionary<string, object> dbParams)
//        {
//            return _DAL.ExecuteBySQL(sqlText, dbParams);
//        }
        
//        #endregion

//        #region 判断字段值是否存在

//        public virtual bool IsExist(object pkeyValue, string fieldName, object fieldValue, string sqlWhere, Dictionary<string, object> dbParams)
//        {
//            return _DAL.IsExist(pkeyValue, fieldName, fieldValue, sqlWhere, dbParams);
//        }
//        public bool IsExist(string fieldName, object fieldValue, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return IsExist(null, fieldName, fieldValue, sqlWhere.ToString(), dbParam);
//        }
//        public bool IsExist(string fieldName, object fieldValue, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return IsExist(null, fieldName, fieldValue, sqlWhere.ToString(), dbParam);
//        }

//        #endregion

//        #region 获得首行首列的方法

//        /// <summary>
//        /// 根据主键获得一个指定字段的值
//        /// </summary>
//        public virtual object GetObjectByField(string fieldName, object pkValue)
//        {
//            return _DAL.GetObjectByField(fieldName, pkValue);
//        }

//        #endregion

//        #region 根据主键获得一个实体

//        public virtual TModel GetModel(object id)
//        {
//            return _DAL.GetModel(id);
//        }

//        #endregion

//        #region 获得记录数

//        public virtual int GetRecordCount(string sqlWhere, Dictionary<string, object> dbParams)
//        {
//            return _DAL.GetRecordCount(sqlWhere, dbParams);
//        }
//        public int GetRecordCount()
//        {
//            return GetRecordCount(string.Empty, null);
//        }
//        public int GetRecordCount(params DbWhereModel[] whereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParams = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParams, whereModel);
//            return GetRecordCount(sqlWhere.ToString(), dbParams);
//        }
//        public int GetRecordCount(params DbWhereModel[][] whereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParams = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParams, whereModel);
//            return GetRecordCount(sqlWhere.ToString(), dbParams);
//        }
//        #endregion

//        #region 设置必须查询的where参数

//        /// <summary>
//        /// 必须的查询条件,可用于同一操作员只能查看自己的数据,或去除删除数据的筛选
//        /// </summary>
//        protected virtual DbWhereModel[] MustSearchWhereParam
//        {
//            get { return null; }
//        }
//        /// <summary>
//        /// 设置必须查询的参数,并重新输入sqlWhere查询条件及参数
//        /// </summary>
//        /// <param name="sqlWhere">输入的sqlWhere语句,加入必须参数后重新输出</param>
//        /// <param name="dbParams">输入的sql参数对象,加入必须参数后重新输出</param>
//        private void SetMustSearchWhereParam(ref string sqlWhere, ref Dictionary<string, object> dbParams)
//        {
//            if (MustSearchWhereParam != null && MustSearchWhereParam.Length > 0)
//            {
//                StringBuilder sbWhere = null;
//                if (sqlWhere != null && sqlWhere.Trim().Length > 1)
//                {
//                    sbWhere = new StringBuilder(sqlWhere);
//                }
//                GetSqlWhereParam(ref sbWhere, ref dbParams, MustSearchWhereParam);
//                sqlWhere = sbWhere.ToString();
//            }
//        }

//        #endregion

//        #region 设置搜索的注册搜索规则

//        //注册搜索参数
//        void RegisterSearchParam(string sqlWhere, Dictionary<string, object> dbParams)
//        {
//            if (SearchBefore != null)
//            {
//                DbWhereModel[] searchWhereParam;
//                SearchBefore(out searchWhereParam);
//                if (searchWhereParam != null && searchWhereParam.Length > 0)
//                {
//                    StringBuilder sbWhere = null;
//                    if (sqlWhere != null && sqlWhere.Trim().Length > 1)
//                    {
//                        sbWhere = new StringBuilder(sqlWhere);
//                    }
//                    GetSqlWhereParam(ref sbWhere, ref dbParams, searchWhereParam);
//                    sqlWhere = sbWhere.ToString();
//                }
//            }
//        }

//        #endregion

//        #region 获得DataTable

//        public virtual DataTable GetDataTableBySQL(string sql, Dictionary<string, object> dbParams)
//        {
//            return _DAL.GetDataTableBySQL(sql, dbParams);
//        }

//        #region 条件查询的几个重载(不分页)

//        /// <summary>
//        /// 主方法,其他重载都由此方法而生
//        /// </summary>
//        /// <param name="sqlWhere">SQL where条件</param>
//        /// <param name="dbParams">sql文本中所对应的参数</param>
//        /// <param name="orderFields">排序字段</param>
//        /// <param name="isDesc">是否降序,false:为升序</param>
//        /// <param name="selectFields">要显示的字段,select 查询</param>
//        /// <returns>返回DataTable</returns>
//        public virtual DataTable GetDataTable(string sqlWhere, Dictionary<string, object> dbParams, string[] orderFields, bool isDesc, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetDataTable(sqlWhere, dbParams, orderFields, isDesc, selectFields);
//        }

//        public virtual DataTable GetDataTable(string[] selectFields, string[] orderFields, bool isDesc, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTable(sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual DataTable GetDataTable(string[] selectFields, string[] orderFields, bool isDesc, params DbWhereModel[] dbWhereModel)
//        {

//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTable(sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual DataTable GetDataTable(string[] selectFields, params DbWhereModel[][] dbWhereModel)
//        {

//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTable(sqlWhere.ToString(), dbParam, null, false, selectFields);
//        }
//        public virtual DataTable GetDataTable(string[] selectFields, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTable(sqlWhere.ToString(), dbParam, null, false, selectFields);
//        }
//        public virtual DataTable GetDataTable(params DbWhereModel[][] dbWhereModel)
//        {
//            return GetDataTable(null, dbWhereModel);
//        }
//        public virtual DataTable GetDataTable(params DbWhereModel[] dbWhereModel)
//        {
//            return GetDataTable(null, null, false, dbWhereModel);
//        }
//        public virtual DataTable GetDataTable()
//        {
//            return GetDataTable(null, null, null, false, null);
//        }

//        #endregion

//        #region 获得分页的几个重载

//        public virtual DataTable GetDataTableByPage(int onePageCount, int pageNo, bool isDesc, string[] orderField, out int pageCount, out int recordCount, string sqlWhere, Dictionary<string, object> dbParams, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetDataTableByPage(onePageCount, pageNo, isDesc, orderField, out pageCount, out recordCount, sqlWhere, dbParams, selectFields);
//        }

//        public virtual DataTable GetDataTableByPage(string[] selectFields, DbPagingModel padingModel, params DbWhereModel[][] dbWhereModel)
//        {
//            int pageCount, recordCount;
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DataTable dt =
//             GetDataTableByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                sqlWhere.ToString(),
//                dbParam,
//                selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return dt;
//        }
//        public virtual DataTable GetDataTableByPage(string[] selectFields, DbPagingModel padingModel, params DbWhereModel[] dbWhereModel)
//        {
//            int pageCount, recordCount;
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DataTable dt = GetDataTableByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                sqlWhere.ToString(), dbParam, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return dt;
//        }
//        public virtual DataTable GetDataTableByPage(string[] selectFields, DbPagingModel padingModel)
//        {
//            int pageCount, recordCount;
//            DataTable dt = GetDataTableByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                null, null, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return dt;
//        }
//        public virtual DataTable GetDataTableByPage(DbPagingModel padingModel, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetDataTableByPage(null, padingModel, dbWhereModel);
//        }
//        public virtual DataTable GetDataTableByPage(DbPagingModel padingModel, params DbWhereModel[] dbWhereModel)
//        {
//            return GetDataTableByPage(null, padingModel, dbWhereModel);
//        }
//        public virtual DataTable GetDataTableByPage(DbPagingModel padingModel)
//        {
//            int pageCount, recordCount;
//            DataTable dt = GetDataTableByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                null, null, null);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return dt;
//        }

//        #endregion

//        #region 获得前几行的几个重载方法

//        public virtual DataTable GetDataTableTopCount(int topCount, string sqlWhere, Dictionary<string, object> dbParams, string[] orderFields, bool isDesc, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetDataTableTopCount(topCount, sqlWhere, dbParams, orderFields, false, selectFields);
//        }

//        public virtual DataTable GetDataTableTopCount(string[] selectFields, int topCount, string[] orderFields, bool isDesc, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTableTopCount(topCount, sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual DataTable GetDataTableTopCount(string[] selectFields, int topCount, string[] orderFields, bool isDesc, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTableTopCount(topCount, sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual DataTable GetDataTableTopCount(string[] selectFields, int topCount, string[] orderFields, bool isDesc)
//        {
//            //StringBuilder sqlWhere = null;
//            //Dictionary<string, object> dbParam = null;
//            //GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetDataTableTopCount(topCount, null, null, orderFields, isDesc, selectFields);
//        }

//        public virtual DataTable GetDataTableTopCount(string[] selectFields, int topCount, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetDataTableTopCount(selectFields, topCount, null, false, dbWhereModel);
//        }
//        public virtual DataTable GetDataTableTopCount(string[] selectFields, int topCount, params DbWhereModel[] dbWhereModel)
//        {
//            return GetDataTableTopCount(selectFields, topCount, null, false, dbWhereModel);
//        }
//        public virtual DataTable GetDataTableTopCount(string[] selectFields, int topCount)
//        {
//            return GetDataTableTopCount(selectFields, topCount, null, false);
//        }

//        public virtual DataTable GetDataTableTopCount(int topCount, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetDataTableTopCount(null, topCount, null, false, dbWhereModel);
//        }
//        public virtual DataTable GetDataTableTopCount(int topCount, params DbWhereModel[] dbWhereModel)
//        {
//            return GetDataTableTopCount(null, topCount, null, false, dbWhereModel);
//        }
//        public virtual DataTable GetDataTableTopCount(int topCount)
//        {
//            return GetDataTableTopCount(null, topCount, null, false);
//        }


//        #endregion

//        #endregion

//        #region 获取DataReader

//        #region 条件查询的几个重载

//        public virtual DbDataReader GetDataReaderBySQL(string sql, Dictionary<string, object> dbParams)
//        {
//            return _DAL.GetDataReaderBySQL(sql, dbParams);
//        }

//        //其它重载方法由此方法衍生
//        public DbDataReader GetDataReader(string sqlWhere, Dictionary<string, object> dbParams, string[] orderFields, bool isDesc, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetDataReader(sqlWhere, dbParams, orderFields, isDesc);
//        }

//        #region 执行DataReader的逐行读取操作,交由一个委托来处理每行数据

//        //执行DataReader交个一个委托来处理
//        protected virtual void ExecDataReader(DbDataReader dbReader, DbDataReaderHandle ReaderHandle)
//        {
//            using (dbReader)
//            {
//                if (dbReader.HasRows)
//                {
//                    bool isNewRow = false;
//                    while (dbReader.Read())
//                    {
//                        for (int i = 0; i < dbReader.FieldCount; i++)
//                        {
//                            string cName = dbReader.GetName(i);
//                            //dbDetail.Add(cName, dbReader[i]);
//                            isNewRow = i == dbReader.FieldCount - 1 ? true : false;
//                            ReaderHandle(cName, dbReader[i], isNewRow);
//                        }
//                    }
//                }
//            }
//        }

//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, string[] selectFields, string[] orderFields, bool isDesc, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DbDataReader reader = GetDataReader(sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//            ExecDataReader(reader, ReaderHandle);
//        }
//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, string[] selectFields, string[] orderFields, bool isDesc, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DbDataReader reader = GetDataReader(sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//            ExecDataReader(reader, ReaderHandle);
//        }
//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, string[] selectFields, string[] orderFields, bool isDesc)
//        {
//            DbDataReader reader = GetDataReader(null, null, orderFields, isDesc, selectFields);
//            ExecDataReader(reader, ReaderHandle);
//        }

//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, string[] selectFields, params DbWhereModel[][] dbWhereModel)
//        {
//            ExecDataReader(ReaderHandle, selectFields, null, false, dbWhereModel);
//        }
//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, string[] selectFields, params DbWhereModel[] dbWhereModel)
//        {
//            ExecDataReader(ReaderHandle, selectFields, null, false, dbWhereModel);
//        }
//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, string[] selectFields)
//        {
//            ExecDataReader(ReaderHandle, selectFields, null, false);
//        }

//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, params DbWhereModel[][] dbWhereModel)
//        {
//            ExecDataReader(ReaderHandle, null, null, false, dbWhereModel);
//        }
//        public void ExecDataReader(DbDataReaderHandle ReaderHandle, params DbWhereModel[] dbWhereModel)
//        {
//            ExecDataReader(ReaderHandle, null, null, false, dbWhereModel);
//        }
//        public void ExecDataReader(DbDataReaderHandle ReaderHandle)
//        {
//            ExecDataReader(ReaderHandle, null, null, false);
//        }

//        #endregion

//        #endregion

//        #region 获得分页数据的几个重载

//        public virtual DbDataReader GetDataReaderByPage(int onePageCount, int pageNo, bool isDesc, string[] orderField, out int pageCount, out int recordCount, string sqlWhere, Dictionary<string, object> dbParams, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetDataReaderByPage(onePageCount, pageNo, isDesc, orderField, out pageCount, out recordCount, sqlWhere, dbParams, selectFields);
//        }
//        public void GetDataReaderByPage(DbDataReaderHandle ReaderHandle, string[] selectFields, DbPagingModel padingModel, params DbWhereModel[][] dbWhereModel)
//        {
//            int pageCount, recordCount;
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DbDataReader reader = GetDataReaderByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                sqlWhere.ToString(), dbParam, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            ExecDataReader(reader, ReaderHandle);
//        }
//        public void GetDataReaderByPage(DbDataReaderHandle ReaderHandle, string[] selectFields, DbPagingModel padingModel, params DbWhereModel[] dbWhereModel)
//        {
//            int pageCount, recordCount;
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DbDataReader reader = GetDataReaderByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                sqlWhere.ToString(), dbParam, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            ExecDataReader(reader, ReaderHandle);
//        }
//        public void GetDataReaderByPage(DbDataReaderHandle ReaderHandle, string[] selectFields, DbPagingModel padingModel)
//        {
//            int pageCount, recordCount;
//            DbDataReader reader = GetDataReaderByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                null, null, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            ExecDataReader(reader, ReaderHandle);
//        }

//        public void GetDataReaderByPage(DbDataReaderHandle ReaderHandle, DbPagingModel padingModel, params DbWhereModel[][] dbWhereModel)
//        {
//            GetDataReaderByPage(ReaderHandle, null, padingModel, dbWhereModel);
//        }
//        public void GetDataReaderByPage(DbDataReaderHandle ReaderHandle, DbPagingModel padingModel, params DbWhereModel[] dbWhereModel)
//        {
//            GetDataReaderByPage(ReaderHandle, null, padingModel, dbWhereModel);
//        }
//        public void GetDataReaderByPage(DbDataReaderHandle ReaderHandle, DbPagingModel padingModel)
//        {
//            GetDataReaderByPage(ReaderHandle, null, padingModel);
//        }

//        #endregion

//        #region 获得前几行的几个重载

//        public virtual DbDataReader GetDataReaderTopCount(int topCount, string sqlWhere, Dictionary<string, object> dbParams, string[] orderFields, bool isDesc, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetDataReaderTopCount(topCount, sqlWhere, dbParams, orderFields, isDesc, selectFields);
//        }

//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, string[] selectFields, int topCount, string[] orderFields, bool isDesc, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DbDataReader reader = GetDataReaderTopCount(topCount, sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//            ExecDataReader(reader, ReaderHandle);
//        }
//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, string[] selectFields, int topCount, string[] orderFields, bool isDesc, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            DbDataReader reader = GetDataReaderTopCount(topCount, sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//            ExecDataReader(reader, ReaderHandle);
//        }
//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, string[] selectFields, int topCount, string[] orderFields, bool isDesc)
//        {
//            DbDataReader reader = GetDataReaderTopCount(topCount, null, null, orderFields, isDesc, selectFields);
//            ExecDataReader(reader, ReaderHandle);
//        }

//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, string[] selectFields, int topCount, params DbWhereModel[][] dbWhereModel)
//        {
//            GetDataReaderTopCount(ReaderHandle, selectFields, topCount, null, false, dbWhereModel);
//        }
//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, string[] selectFields, int topCount, params DbWhereModel[] dbWhereModel)
//        {
//            GetDataReaderTopCount(ReaderHandle, selectFields, topCount, null, false, dbWhereModel);
//        }
//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, string[] selectFields, int topCount)
//        {
//            GetDataReaderTopCount(ReaderHandle, selectFields, topCount, null, false);
//        }

//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, int topCount, params DbWhereModel[][] dbWhereModel)
//        {
//            GetDataReaderTopCount(ReaderHandle, null, topCount, dbWhereModel);
//        }
//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, int topCount, params DbWhereModel[] dbWhereModel)
//        {
//            GetDataReaderTopCount(ReaderHandle, null, topCount, dbWhereModel);
//        }
//        public void GetDataReaderTopCount(DbDataReaderHandle ReaderHandle, int topCount)
//        {
//            GetDataReaderTopCount(ReaderHandle, null, topCount);
//        }

//        #endregion

//        #endregion

//        #region 获得List集合的几个重载

//        #region 根据where条件数据的几个重载

//        //主方法,其他重载都由此派生
//        public virtual List<TModel> GetList(string sqlWhere, Dictionary<string, object> dbParams, string[] orderFields, bool isDesc, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetList(sqlWhere, dbParams, orderFields, isDesc, selectFields);
//        }

//        public virtual List<TModel> GetList(string[] selectFields, string[] orderFields, bool isDesc, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetList(sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual List<TModel> GetList(string[] selectFields, string[] orderFields, bool isDesc, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetList(sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual List<TModel> GetList(string[] selectFields, string[] orderFields, bool isDesc)
//        {
//            return GetList(null, null, orderFields, isDesc, selectFields);
//        }

//        public virtual List<TModel> GetList(string[] selectFields, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetList(selectFields, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetList(string[] selectFields, params DbWhereModel[] dbWhereModel)
//        {
//            return GetList(selectFields, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetList(string[] selectFields)
//        {
//            return GetList(selectFields, null, false);
//        }
//        public virtual List<TModel> GetList(params DbWhereModel[][] dbWhereModel)
//        {
//            return GetList(null, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetList(params DbWhereModel[] dbWhereModel)
//        {
//            return GetList(null, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetList()
//        {
//            return GetList(null, null, false);
//        }

//        #endregion

//        #region 获得分页数据的几个重载
//        //主方法
//        public List<TModel> GetListByPage(int onePageCount, int pageNo, bool isDesc, string[] orderField, out int pageCount, out int recordCount, string sqlWhere, Dictionary<string, object> dbParams, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetListByPage(onePageCount, pageNo, isDesc, orderField, out pageCount, out recordCount, sqlWhere, dbParams, selectFields);
//        }

//        public List<TModel> GetListByPage(string[] selectFields, DbPagingModel padingModel, params DbWhereModel[][] dbWhereModel)
//        {
//            int pageCount, recordCount;
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            List<TModel> list = GetListByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                sqlWhere.ToString(), dbParam, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return list;
//        }
//        public List<TModel> GetListByPage(string[] selectFields, DbPagingModel padingModel, params DbWhereModel[] dbWhereModel)
//        {
//            int pageCount, recordCount;
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            List<TModel> list = GetListByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                sqlWhere.ToString(), dbParam, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return list;
//        }
//        public List<TModel> GetListByPage(string[] selectFields, DbPagingModel padingModel)
//        {
//            int pageCount, recordCount;
//            List<TModel> list = GetListByPage(
//                padingModel.OnePageCount,
//                padingModel.PageNo,
//                padingModel.IsDesc,
//                padingModel.OrderField,
//                out pageCount,
//                out recordCount,
//                null, null, selectFields);
//            padingModel.PageCount = pageCount;
//            padingModel.RecordCount = recordCount;
//            return list;
//        }
//        public List<TModel> GetListByPage(DbPagingModel padingModel, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetListByPage(null, padingModel, dbWhereModel);
//        }
//        public List<TModel> GetListByPage(DbPagingModel padingModel, params DbWhereModel[] dbWhereModel)
//        {
//            return GetListByPage(null, padingModel, dbWhereModel);
//        }
//        public List<TModel> GetListByPage(DbPagingModel padingModel)
//        {
//            return GetListByPage(null, padingModel);
//        }

//        #endregion

//        #region 获得前几行List的几个重载

//        //主方法
//        public virtual List<TModel> GetListTopCount(int topCount, string sqlWhere, Dictionary<string, object> dbParams, string[] orderFields, bool isDesc, params string[] selectFields)
//        {
//            RegisterSearchParam(sqlWhere, dbParams);
//            return _DAL.GetListTopCount(topCount, sqlWhere, dbParams, orderFields, isDesc, selectFields);
//        }

//        public virtual List<TModel> GetListTopCount(string[] selectFields, int topCount, string[] orderFields, bool isDesc, params DbWhereModel[][] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetListTopCount(topCount, sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual List<TModel> GetListTopCount(string[] selectFields, int topCount, string[] orderFields, bool isDesc, params DbWhereModel[] dbWhereModel)
//        {
//            StringBuilder sqlWhere = null;
//            Dictionary<string, object> dbParam = null;
//            GetSqlWhereParam(ref sqlWhere, ref dbParam, dbWhereModel);
//            return GetListTopCount(topCount, sqlWhere.ToString(), dbParam, orderFields, isDesc, selectFields);
//        }
//        public virtual List<TModel> GetListTopCount(string[] selectFields, int topCount, string[] orderFields, bool isDesc)
//        {
//            return GetListTopCount(topCount, null, null, orderFields, isDesc, selectFields);
//        }

//        public virtual List<TModel> GetListTopCount(string[] selectFields, int topCount, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetListTopCount(selectFields, topCount, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetListTopCount(string[] selectFields, int topCount, params DbWhereModel[] dbWhereModel)
//        {
//            return GetListTopCount(selectFields, topCount, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetListTopCount(string[] selectFields, int topCount)
//        {
//            return GetListTopCount(selectFields, topCount, null, false);
//        }

//        public virtual List<TModel> GetListTopCount(int topCount, params DbWhereModel[][] dbWhereModel)
//        {
//            return GetListTopCount(null, topCount, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetListTopCount(int topCount, params DbWhereModel[] dbWhereModel)
//        {
//            return GetListTopCount(null, topCount, null, false, dbWhereModel);
//        }
//        public virtual List<TModel> GetListTopCount(int topCount)
//        {
//            return GetListTopCount(null, topCount, null, false);
//        }

//        #endregion

//        #endregion

//        #region 执行存储过程

//        public int ExecProcedureGetNon(ProcedureObjBase procObj)
//        {
//            return _DAL.ExecProcedureGetNon(procObj);
//        }

//        public DataTable ExecProcedureGetDataTable(ProcedureObjBase procObj)
//        {
//            return _DAL.ExecProcedureGetDataTable(procObj);
//        }

//        public object ExecProcedureGetObj(ProcedureObjBase procObj)
//        {
//            return _DAL.ExecProcedureGetObj(procObj);
//        }

//        #endregion
//    }
//}